package leetcode;

/**
 * @Project : AlgorithmLearning
 * @Package : Leetcode
 * @File : Q0062.java
 * @Author : WangRuoyu
 * @Date 2023/11/3 22:56
 */


public class Q0062 {
    public int uniquePaths(int m, int n) {
        int[][] f = new int[m][n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (i == 0 || j == 0) {
                    f[i][j] = 1;
                } else {
                    f[i][j] = f[i][j - 1] + f[i - 1][j];
                }
            }
        }
        return f[m - 1][n - 1];
    }

    public static void main(String[] args) {
        Q0062 sl = new Q0062();
        int m = 3, n = 7;
        System.out.println(sl.uniquePaths(m, n));
        m = 3;
        n = 2;
        System.out.println(sl.uniquePaths(m, n));
    }
}